package cn.vcjf.weapp.api.setting.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.setting.entity.PayType;
import cn.vcjf.weapp.api.setting.service.PayTypeService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-25
 */
@Controller
@RequestMapping("/setting/payType")
public class PayTypeController {
     @Resource
     private PayTypeService  payTypeService;

     @RequestMapping("/addPayType")
     @ResponseBody
     public TableResult addPayType(PayType payType){
         payType.preInsert();
         boolean b = payTypeService.insert(payType);
         return TableResult.Result(b);
     }

     @RequestMapping("/updatePayType")
     @ResponseBody
     public TableResult updatePayType(PayType payType){
         payType.preUpdate();
        boolean b = payTypeService.updateById(payType);
         return TableResult.Result(b);
     }

     @RequestMapping("/findPayTypeOne")
     @ResponseBody
     public TableResult findPayTypeOne(PayType payType){

        EntityWrapper<PayType> wrapper = payType.getQueryWrapper();

        PayType result = payTypeService.selectOne(wrapper);

		return TableResult.OKResult(result);
     }

     @RequestMapping("/findPayTypeList")
     @ResponseBody
     public TableResult findPayTypeList(PayType payType){

        EntityWrapper<PayType> wrapper = payType.getQueryWrapper();

        Page<PayType> page = payType.getPageInfo();

        page = payTypeService.selectPage(page,wrapper);

		return TableResult.OKResult(page);

     }

     @RequestMapping("/deletePayType")
     @ResponseBody
     public TableResult deletePayType(PayType payType){
        payType.preUpdate();
        boolean b = payTypeService.deleteById(payType.getId());
        return TableResult.Result(b);
     }

}
